package com.yb.core.util;

/**
 * Copyright (C), 2022-2022, 姚兵
 * Author: 32210
 * Date: 2022/12/6 19:53
 * FileName: VerifyCodeUtil
 * Description:
 */
public class VerifyCodeUtil {

    public static final char[] defaultCodes="0123456789".toCharArray();
    public static String generateCode(int length){

        if(length<=0)return "";
        StringBuilder sb=new StringBuilder();
        for (int i = 0; i < length; i++) {
            sb.append(defaultCodes[(int) (Math.random()*defaultCodes.length)]);
        }
        return sb.toString();
    }

    public static String generateNumCode(int length){

        if(length<=0)return "";
        StringBuilder sb=new StringBuilder();
        for (int i = 0; i < length; i++) {
            sb.append(defaultCodes[(int) (Math.random()*defaultCodes.length)]);
        }
        return sb.toString();
    }
}
